////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		CBaseObject.h
//
//		Author			:		Kevin Jordan
//
//		Purpose			:		Header to contain all generic functionality of the BaseObject and its childeren
//
//		Dates			:		Written( Feb 13, 2011 ) by Kevin Jordan		LastUpdate( Feb 13, 2011  ) by Kevin Jordan 
//	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "CBaseObject.h"
#include "SGD Wrappers/CSGD_TextureManager.h"


CBaseObject::CBaseObject()
{

	m_uiRefCount = 1;

	m_VecPosition.SetX(0);
	m_VecPosition.SetY(0);

	m_VecVelocity.SetX(0);
	m_VecVelocity.SetY(0);

	m_nHP = 0;
	m_nWidth = 0;
	m_nHeight = 0;

	m_nImageID = 0;
}


CBaseObject::~CBaseObject()
{

}


RECT CBaseObject::GetRect()
{
	RECT TempRect;

	SetRect( &TempRect, (int)GetPosX(), (int)GetPosY(), (int)GetPosX() + GetWidth(), (int)GetPosY() + GetHeight() );

	return TempRect;
}


bool CBaseObject::CheckCollision( IBaseInterface* pBase )
{
	RECT TempRect;

	if(IntersectRect( &TempRect, &this->GetRect(),&pBase->GetRect()))
		return true;

	return false;
}

void CBaseObject::Render()
{
	CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();

	pTM->Draw( GetImageID(), (int)GetPosX(), (int)GetPosY() );
}

void CBaseObject::Update(float fElapsedTime )
{
	SetPosX( GetPosX() + ( GetVelX() * fElapsedTime ));
	SetPosY( GetPosY() + ( GetVelY() * fElapsedTime ));
}

bool CBaseObject::Input()
{
	return true;
}